const baseurl = 'http://192.168.18.111:8080/v1/health'

function _request(url, data, method) {
  return new Promise((resolve, reject) => {
    uni.request({
      url: baseurl + url,
      data:data,
      method:method,
      header: {
        'content-type': 'application/json',
		'Authorization': uni.getStorageSync('token')
      },
      success: function(res) {
        resolve(res.data);
      },
      fail: function(res) {
        reject(res);
      }
    })
  })
}

const get = (url, data) => {
  return _request(url, data, 'GET');
}

const post = (url, data) => {
  return _request(url, data, 'POST');
}

const put = (url, data) => {
  return _request(url, data, 'PUT');
}

const request = {
	get,
	post,
	put

}

export default request
